package cn.xinfei.xdecision.common.service.component.decisiontree.impl;

import cn.xinfei.xdecision.common.dao.component.decisiontree.DecisionTreeDetailConditionMapper;
import cn.xinfei.xdecision.common.dao.component.decisiontree.DecisionTreeMapper;
import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.component.ComponentVersionVo;
import cn.xinfei.xdecision.common.model.component.ComponentVo;
import cn.xinfei.xdecision.common.model.component.CopyToFolderReqVo;
import cn.xinfei.xdecision.common.model.component.decisiontree.DecisionTree;
import cn.xinfei.xdecision.common.model.component.decisiontree.DecisionTreeVersion;
import cn.xinfei.xdecision.common.model.component.decisiontree.vo.DecisionTreeVersionVo;
import cn.xinfei.xdecision.common.model.component.decisiontree.vo.DecisionTreeVo;
import cn.xinfei.xdecision.common.model.component.dependency.EngineNodeComponentRel;
import cn.xinfei.xdecision.common.model.component.dependency.resp.DecisionComponentDependencyResp;
import cn.xinfei.xdecision.common.model.component.guiderule.vo.RuleListReqVo;
import cn.xinfei.xdecision.common.model.component.request.ListParam;
import cn.xinfei.xdecision.common.model.login.SessionManager;
import cn.xinfei.xdecision.common.service.common.sso.SSOService;
import cn.xinfei.xdecision.common.service.common.sso.dto.SSOUserInfoReqDto;
import cn.xinfei.xdecision.common.service.common.sso.dto.SSOUserInfoRespDto;
import cn.xinfei.xdecision.common.service.component.ComponentCommonContext;
import cn.xinfei.xdecision.common.service.component.ComponentCommonService;
import cn.xinfei.xdecision.common.service.component.decisiontree.DecisionTreeService;
import cn.xinfei.xdecision.common.service.component.decisiontree.DecisionTreeVersionService;
import cn.xinfei.xdecision.common.service.component.dependency.EngineNodeComponentRelService;
import cn.xinfei.xdecision.common.service.utils.CodeGenerateUtil;
import cn.xinfei.xdecision.common.utils.constant.SysConstant;
import cn.xinfei.xdecision.common.utils.enums.enginex.ComponentStatusEnum;
import cn.xinfei.xdecision.common.utils.enums.enginex.ComponentVersionStatusEnum;
import cn.xinfei.xdecision.common.utils.exception.ApiException;
import cn.xinfei.xdecision.common.utils.exception.enums.ErrorCodeEnum;
import cn.xinfei.xdecision.common.utils.util.BeanUtilsPlus;
import cn.xinfei.xdecision.common.utils.util.FutureUtils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

import static cn.xinfei.xdecision.common.utils.exception.enums.ErrorCodeEnum.COMPONENT_COPY_ERROR;
import static cn.xinfei.xdecision.common.utils.exception.util.ApiExceptionUtil.exception;

@Service("decisionTreeService")
@Slf4j
public class DecisionTreeServiceImpl extends ServiceImpl<DecisionTreeMapper, DecisionTree> implements DecisionTreeService, ComponentCommonService {

    @Resource
    private DecisionTreeMapper decisionTreeMapper;

    @Resource
    private DecisionTreeVersionService versionService;

    @Resource
    private DecisionTreeDetailConditionMapper decisionTreeDetailConditionMapper;

    @Resource
    private SSOService ssoService;

    @Resource
    private TransactionTemplate transactionTemplate;

    @Resource
    private CodeGenerateUtil codeGenerateUtil;

    @Resource
    private DecisionTreeServiceImpl decisionTreeService;

    @Resource(name = "componentAsyncExecutor")
    private ExecutorService bizProcessorThreadPool;

    @Resource
    private EngineNodeComponentRelService engineNodeComponentRelService;

    @Override
    public DecisionTreeVo queryById(Long id) {
        DecisionTreeVo decisionTreeVo = new DecisionTreeVo();
        //主表信息
        DecisionTree decisionTree = this.getById(id);
        if (Objects.isNull(decisionTree)) {
            return decisionTreeVo;
        }
        BeanUtils.copyProperties(decisionTree, decisionTreeVo);
        //规则状态描述
        decisionTreeVo.setStatusDesc(Objects.requireNonNull(ComponentStatusEnum.get(decisionTreeVo.getStatus())).getName());
        //全部版本信息
        List<DecisionTreeVersionVo> treeVersionVos = versionService.queryVersionByTreeCodes(
                Collections.singletonList(decisionTreeVo.getCode()), null);
        if (CollectionUtils.isEmpty(treeVersionVos)) {
            return decisionTreeVo;
        }
        //当前版本
        DecisionTreeVersionVo decisionTreeVersionVo = treeVersionVos.stream()
                .max(Comparator.comparing(DecisionTreeVersionVo::getId)).orElse(null);
        if (Objects.isNull(decisionTreeVersionVo)) {
            return decisionTreeVo;
        }
        decisionTreeVo.setLastVersionStatus(decisionTreeVersionVo.getStatus())
                //最新版本状态描述
                .setLastVersionStatusDesc(Objects.requireNonNull(ComponentVersionStatusEnum.get(decisionTreeVersionVo.getStatus())).getName())
                //当前版本
                .setLastVersion(decisionTreeVersionVo.getVersionNo())
                //版本说明
                .setVersionDesc(decisionTreeVersionVo.getDescription())
                //是否存在新建版本
                .setIsNewVersion(treeVersionVos.stream().anyMatch(x -> Objects.equals(x.getStatus(), ComponentVersionStatusEnum.NEW.getStatus())))
                .setVersionList(Lists.newArrayList(decisionTreeVersionVo));
        return decisionTreeVo;
    }

    @Override
    public ResponseEntityDto<PageResult<List<DecisionTreeVo>, DecisionTree>> queryByEntity(ListParam listParam) {
        List<Long> orgIdList = SessionManager.getLoginAccount().getOrgIdList();
        if (CollectionUtils.isEmpty(orgIdList)) {
            return ResponseEntityDto.success(new PageResult<>());
        }
        //决策树
        LambdaUpdateWrapper<DecisionTree> lbd = new LambdaUpdateWrapper<>();
        if (StringUtils.isNotEmpty(listParam.getCondition())) {
            lbd.eq(DecisionTree::getCode, listParam.getCondition())
                    .or().like(DecisionTree::getName, listParam.getCondition());
        }
        if (Objects.nonNull(listParam.getFolderId())) {
            lbd.eq(DecisionTree::getFolderId, listParam.getFolderId());
        }
        lbd.in(DecisionTree::getOrganId, orgIdList);
        PageMethod.startPage(listParam.getPageNo(), listParam.getPageSize());
        //排序按照启用，更新时间倒叙
        List<DecisionTree> decisionTrees = this.list(lbd.last("order by status = 1 desc,updated_time desc"));
        if (CollectionUtils.isEmpty(decisionTrees)) {
            return PageResult.success(new ArrayList<>(), new PageInfo<>());
        }
        PageInfo<DecisionTree> pageInfo = new PageInfo<>(decisionTrees);
        List<DecisionTreeVo> decisionTreeVos = BeanUtilsPlus.copyElements(decisionTrees, DecisionTreeVo::new);
        //版本号
        List<DecisionTreeVersionVo> decisionTreeVersionVos = versionService.queryVersionByTreeCodes(
                decisionTreeVos.stream().map(DecisionTreeVo::getCode).collect(Collectors.toList()), null);
        //最新版本号
        Map<String, List<DecisionTreeVersionVo>> versionMap = decisionTreeVersionVos
                .stream().collect(Collectors.groupingBy(DecisionTreeVersionVo::getDecisionTreeCode));
        //更新人信息
        SSOUserInfoReqDto ssoUserInfoReqDto = new SSOUserInfoReqDto();
        ssoUserInfoReqDto.setId(new ArrayList<>(
                decisionTrees.stream().map(DecisionTree::getUpdateUserId).collect(Collectors.toSet())));
        Map<Long, String> sysMap = ssoService.getUserInfos(ssoUserInfoReqDto).stream()
                .collect(Collectors.toMap(SSOUserInfoRespDto::getId, SSOUserInfoRespDto::getName));
        decisionTreeVos.forEach(x -> {
                    List<DecisionTreeVersionVo> versionVos = versionMap.getOrDefault(x.getCode(), new ArrayList<>());
                    //状态描述
                    x.setStatusDesc(Objects.requireNonNull(ComponentStatusEnum.get(x.getStatus())).getName())
                            //更新人信息
                            .setUpdatedUserName(sysMap.getOrDefault(x.getUpdateUserId(), SysConstant.EMPTY_STRING))
                            //版本集合
                            .setVersionList(versionVos);
                    //最新版本号
                    Long lastVersion = versionVos.stream()
                            .max(Comparator.comparing(DecisionTreeVersionVo::getVersionNo))
                            .map(DecisionTreeVersionVo::getVersionNo).orElse(0L);
                    x.setLastVersion(lastVersion).setLastVersionDesc("V" + lastVersion);
                }
        );
        return PageResult.success(decisionTreeVos, pageInfo);
    }


    @Override
    @Transactional
    public boolean updateStatus(List<Long> ids, Integer status) {
        LambdaUpdateWrapper<DecisionTree> wrapper = new LambdaUpdateWrapper<>();
        wrapper.in(DecisionTree::getId, ids);
        DecisionTree decisionTree = new DecisionTree();
        decisionTree.setStatus(status);
        int updateNum = decisionTreeMapper.update(decisionTree, wrapper);
        if (updateNum > 0) {
            return true;
        }
        return false;
    }

    @Override
    @Transactional
    public boolean updateFolder(List<Long> ids, Long folderId) {
        LambdaUpdateWrapper<DecisionTree> wrapper = new LambdaUpdateWrapper<>();
        wrapper.in(DecisionTree::getId, ids);
        DecisionTree decisionTree = new DecisionTree();
        decisionTree.setFolderId(folderId);
        int updateNum = decisionTreeMapper.update(decisionTree, wrapper);
        if (updateNum > 0) {
            return true;
        }
        return false;
    }

    @Override
    public List<String> queryFieldEnByVersionId(Long versionId) {
        return versionService.queryFieldEnByVersionId(versionId);
    }

    //新插入数据的准备工作
    private void initParam(DecisionTreeVo vo) {
        this.checkUniqueness(vo);
        vo.setOrganId(SessionManager.getLoginAccount().getOrganId());
    }

    //唯一性检查
    private void checkUniqueness(DecisionTreeVo vo) {
        DecisionTree decisionTree = new DecisionTree();
        decisionTree.setName(vo.getName());
        decisionTree.setFolderId(vo.getFolderId());
        DecisionTree info = this.getOne(new QueryWrapper<>(decisionTree), false);
        if (info != null) {
            throw new ApiException(ErrorCodeEnum.DECISION_NAME_REPEAT.getCode(), ErrorCodeEnum.DECISION_NAME_REPEAT.getMessage());
        }
    }

    @Override
    public DecisionTreeVo queryExecuteDecisionTreeByVersionNo(String decisionTreeCode, Long versionNO) {
        List<DecisionTreeVersionVo> versionVos = versionService.queryVersionByTreeCodes(decisionTreeCode, versionNO);
        if (CollectionUtils.isEmpty(versionVos)) {
            return null;
        }
        DecisionTreeVersionVo versionVo = versionVos.get(0);
        LambdaQueryWrapper<DecisionTree> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DecisionTree::getCode, decisionTreeCode);
        DecisionTree decisionTree = decisionTreeMapper.selectOne(wrapper);

        DecisionTreeVo decisionTreeVo = new DecisionTreeVo();
        BeanUtils.copyProperties(decisionTree, decisionTreeVo);
        //decisionTreeVo.setDecisionTreeVersionVoList(versionVo);


//        decisionTreeVo.setVersionList(versionService.queryVersionListByDecisionTreeId(id));
        decisionTreeVo.setExecuteVersion(versionVo);
        return decisionTreeVo;
    }

    @Override
    public DecisionTreeVo queryExecuteDecisionTree(String decisionTreeCode, Long versionId) {
        if (versionId == null) {
            return null;
        }
        DecisionTreeVersionVo versionVo = versionService.queryById(versionId);
        if (versionVo == null) {
            return null;
        }
        if (decisionTreeCode == null) {
            decisionTreeCode = versionVo.getDecisionTreeCode();
        } else if (decisionTreeCode.equals(versionVo.getDecisionTreeCode()) == false) {
            return null;
        }
        LambdaQueryWrapper<DecisionTree> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(DecisionTree::getCode, decisionTreeCode);
        DecisionTree decisionTree = decisionTreeMapper.selectOne(wrapper);
        if (decisionTree == null) {
            return null;
        }
        DecisionTreeVo decisionTreeVo = new DecisionTreeVo();
        BeanUtils.copyProperties(decisionTree, decisionTreeVo);
        //decisionTreeVo.setDecisionTreeVersionVoList(versionVo);


//        decisionTreeVo.setVersionList(versionService.queryVersionListByDecisionTreeId(id));
        decisionTreeVo.setExecuteVersion(versionVo);

        return decisionTreeVo;
    }


    @Override
    public List<Long> getNodeFieldIds(Long versionId) {
//        List<String> list = versionService.queryFieldEnByVersionIdRunner(versionId);
//        List<Field> fieldList = fieldService.selectFieldListByEns(list);
//        Iterator<Field> iterator = fieldList.iterator();
//        List<Long> ids = new ArrayList<>();
//        while (iterator.hasNext()) {
//            ids.add(iterator.next().getId());
//        }
//        return ids;
        return null;
    }

    @Override
    public void updateDecisionTree(List<Long> ids, Integer status, String errorMsg) {
        List<DecisionTree> decisionTrees = this.listByIds(ids);
        String errInfo = decisionTrees.stream()
                .filter(x -> Objects.equals(x.getStatus(), status))
                .map(DecisionTree::getCode).collect(Collectors.joining(SysConstant.COMMA));
        if (StringUtils.isNotEmpty(errInfo)) {
            throw new ApiException(
                    ErrorCodeEnum.DECISION_UPDATE_ERROR.getCode()
                    , ErrorCodeEnum.DECISION_UPDATE_ERROR.getMessage() + "," + errorMsg + ",决策树规则编号：" + errInfo);
        }

        //停用时需校验是否被决策流依赖
        if (ComponentStatusEnum.DISABLE.getStatus().equals(status)) {
            List<EngineNodeComponentRel> dependencies =
                    engineNodeComponentRelService.getRelByComponentCode(decisionTrees.stream().map(DecisionTree::getCode).collect(Collectors.toList()));
            if (!CollectionUtils.isEmpty(dependencies)) {
                throw exception(
                        ErrorCodeEnum.COMPONENT_STATUS_UPDATE_ERROR,
                        "存在依赖关系",
                        dependencies.stream()
                                .map(EngineNodeComponentRel::getComponentCode)
                                .distinct()
                                .collect(Collectors.joining(SysConstant.COMMA)));
            }
        }

        DecisionTree decisionTree = new DecisionTree();
        decisionTree.setStatus(status);
        this.update(decisionTree, new LambdaQueryWrapper<DecisionTree>().in(DecisionTree::getId, ids));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Long checkAndSaveTrees(DecisionTreeVo decisionTreeVo) {
        if (StringUtils.isEmpty(decisionTreeVo.getName())) {
            throw new ApiException(ErrorCodeEnum.NAME_CAN_NOT_BE_NULL);
        }
        //只能修改最新版本状态为‘新建’的规则
        if (!CollectionUtils.isEmpty(decisionTreeVo.getVersionList())) {
            DecisionTreeVersionVo decisionTreeVersionVo = decisionTreeVo.getVersionList().get(0);
            if (!Objects.equals(decisionTreeVersionVo.getStatus(), ComponentVersionStatusEnum.NEW.getStatus())) {
                throw new ApiException(ErrorCodeEnum.DECISION_SAVE_PRE_CHECK_ERROR_001);
            }
            //判断当前版本的状态和传进来的状态是否一致
            checkVersionStatus(decisionTreeVersionVo);
            decisionTreeVo.getVersionList().forEach(DecisionTreeVersionVo::recursionNodeType);
        }
        //decisionTreeVo.setStatus(ComponentStatusEnum.NEW.getStatus());
        //保存
        saveDecisionTree(decisionTreeVo);
        return decisionTreeVo.getId();
    }

    private void checkVersionStatus(DecisionTreeVersionVo decisionTreeVersionVo) {
        if (Objects.nonNull(decisionTreeVersionVo.getId()) && Objects.nonNull(decisionTreeVersionVo.getStatus())) {
            DecisionTreeVersion decisionTreeVersion = versionService.getById(decisionTreeVersionVo.getId());
            if (!Objects.equals(decisionTreeVersion.getStatus(), decisionTreeVersionVo.getStatus())) {
                log.error("传进来的版本状态和数据库中不一致，入参==》{}", JSON.toJSONString(decisionTreeVersion));
                throw new ApiException(ErrorCodeEnum.PARAMS_EXCEPTION.getCode(),
                        ErrorCodeEnum.PARAMS_EXCEPTION.getMessage());
            }
        }
    }

    @Override
    public void copyDecisionTree(CopyToFolderReqVo req) {
        //查询决策树主表信息
        List<DecisionTree> decisionTrees = this.listByIds(req.getIds());
        if (CollectionUtils.isEmpty(decisionTrees)) {
            return;
        }
        List<Future<Void>> allFutureList = Lists.newArrayList();
        List<String> errorCodeList = new CopyOnWriteArrayList<>();
        decisionTrees.forEach(x -> allFutureList.add(CompletableFuture.runAsync(() -> {
            //查询规则
            x.setUpdateUserId(null);
            x.setUpdatedTime(null);
            DecisionTreeVo decisionTreeVo = BeanUtilsPlus.copyProperties(x, DecisionTreeVo::new);
            decisionTreeVo.setName(req.getNamePrefix() + decisionTreeVo.getName() + req.getNameSuffix());
            decisionTreeVo.setFolderId(req.getFolderId());
            decisionTreeVo.setId(null);
            //查询全部版本信息
            List<Long> versionIds =
                    versionService.queryVersionByTreeCodes(Collections.singletonList(decisionTreeVo.getCode()), null)
                            .stream().map(DecisionTreeVersionVo::getId).collect(Collectors.toList());
            //查询明细
            List<DecisionTreeVersionVo> versionVos =
                    versionIds.stream().map(id -> {
                        DecisionTreeVersionVo versionVo = versionService.queryById(id);
                        versionVo.recurrenceSetIdIsNull();
                        return versionVo;
                    }).collect(Collectors.toList());
            decisionTreeVo.setVersionList(versionVos);
            transactionTemplate.execute(status -> {
                try {
                    decisionTreeVo.setCode(codeGenerateUtil.generateYMDCode(SysConstant.JCS_PREFIX, null));
                    decisionTreeService.saveDecisionTree(decisionTreeVo);
                    return Boolean.TRUE;
                } catch (Exception e) {
                    status.setRollbackOnly();
                    log.error("决策树复制失败，具体信息==>{}", JSON.toJSONString(x), e);
                    errorCodeList.add(x.getCode());
                    return Boolean.FALSE;
                }
            });
        }, bizProcessorThreadPool)));
        allFutureList.forEach(x -> FutureUtils.futureGet(x, ErrorCodeEnum.DECISION_COPY_ERROR));
        if (!CollectionUtils.isEmpty(errorCodeList)) {
            throw exception(COMPONENT_COPY_ERROR, errorCodeList);
        }
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveDecisionTree(DecisionTreeVo decisionTreeVo) {
        if (Objects.isNull(decisionTreeVo.getId())) {
            //初始化基本参数
            initParam(decisionTreeVo);
        }
        //拷贝VO到Info对象
        DecisionTree decisionTree = BeanUtilsPlus.copyProperties(decisionTreeVo, DecisionTree::new);
        if (Objects.nonNull(decisionTree.getId())) {
            decisionTree.setCode(null);
        }
        decisionTree.setOrganId(SessionManager.getLoginAccount().getOrganId());
        boolean save = this.saveOrUpdate(decisionTree);
        decisionTreeVo.setId(decisionTree.getId());
        if (!save) {
            throw new ApiException(ErrorCodeEnum.DECISION_SAVE_ERROR.getCode(), ErrorCodeEnum.DECISION_SAVE_ERROR.getMessage());
        }
        List<DecisionTreeVersionVo> versionList = decisionTreeVo.getVersionList();
        if (!CollectionUtils.isEmpty(versionList)) {
            AtomicLong at = new AtomicLong();
            versionList.forEach(x -> {
                x.setDecisionTreeCode(decisionTreeVo.getCode());
                if (Objects.isNull(x.getId())) {
                    x.setOrganId(SessionManager.getLoginAccount().getOrganId());
                    x.setVersionNo(at.incrementAndGet());
                }
            });
            //保存版本
            versionService.addVersionList(versionList);
        }
    }

    @Override
    public List<Long> queryByFolderId(Long folderId) {
        List<DecisionTree> list = this.list(new LambdaQueryWrapper<DecisionTree>()
                .select(DecisionTree::getId)
                .eq(DecisionTree::getFolderId, folderId));

        if (!CollectionUtils.isEmpty(list)) {
            return list.stream().map(DecisionTree::getId).collect(Collectors.toList());
        }
        return new ArrayList<>();
    }

    @Override
    public void logicalDelete(List<Long> ids) {
        this.removeByIds(ids);
    }

    @Override
    public Boolean hasNewVersion(String ruleCode) {
        return !versionService.queryVersionByTreeCodes(
                Collections.singletonList(ruleCode), ComponentVersionStatusEnum.NEW.getStatus()).isEmpty();
    }

    @Override
    public List<ComponentVo> listComponentInfoByIds(String ids) {
        //主表信息
        List<DecisionTree> decisionTreeList = this.listByIds(Arrays.asList(ids.split(SysConstant.COMMA)));
        if (CollectionUtils.isEmpty(decisionTreeList)) {
            return new ArrayList<>();
        }
        Map<String, List<DecisionTreeVersion>> collect = versionService.queryVersionByTreeCodes(
                decisionTreeList.stream().map(DecisionTree::getCode).collect(Collectors.toList()), ComponentVersionStatusEnum.ENABLE.getStatus()).stream()
                .collect(Collectors.groupingBy(DecisionTreeVersion::getDecisionTreeCode));
        if (collect.isEmpty()) {
            return new ArrayList<>();
        }
        List<ComponentVo> componentVos = BeanUtilsPlus.copyElements(decisionTreeList, ComponentVo::new);
        componentVos.forEach(x -> {
                    List<ComponentVersionVo> componentVersionVos =
                            BeanUtilsPlus.copyElements(collect.get(x.getCode()), ComponentVersionVo::new);
                    ComponentCommonContext.swapVersionNoDesc(componentVersionVos);
                    x.setVersionList(componentVersionVos)
                            .setStatusDesc(Objects.requireNonNull(ComponentStatusEnum.get(x.getStatus())).getName());
                }
        );
        return componentVos;
    }


    @Override
    public List<DecisionComponentDependencyResp> getComponentCodeByVarCodes(List<String> varCodes) {
        return decisionTreeDetailConditionMapper.getComponentCodeByVarCodes(varCodes);
    }

    @Override
    public List<String> getFieldCodesByComponentCodes(List<ComponentVo> componentVoListList) {
        if (CollectionUtils.isEmpty(componentVoListList)) {
            return Collections.emptyList();
        }
        return decisionTreeDetailConditionMapper.getFieldCodesByComponentCodes(componentVoListList);
    }

    @Override
    public List<ComponentVo> listComponentInfoByCon(RuleListReqVo ruleListReqVo) {
        return decisionTreeMapper.listComponentInfoByCon(ruleListReqVo);
    }

}
